<?php
function err2( $str )
{
    global $ui;
    $ui->showErrorpage( "<table width=450 border=0 cellpadding=6 cellspacing=0>".( "<tr align=center><td bgcolor=red><font color=white><b>" ).$str."</b></font></td></tr></table><br>"."<p><input type=button value=关闭 onclick=\"closeMyList();\"></p>"."<script>"." function closeMyList(){\r\n    if(top != self){ window.top.mainFrame.myCloseMyDiv(0); }\r\n    else{ window.close(); } \r\n  }\r\n  if(top != self){ setTimeout(\"if(window.top.mainFrame){window.top.mainFrame.myCloseMyDiv(0);}\",30000); }\r\n  else{ setTimeout(\"window.close();\",30000); }\r\n  </script>" );
    exit();
}

echo "<body onBlur=\"focus()\">\r\n";
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
$ui = new UI();
$items = 0;
$itemsum = 0;
$itemresult = 0;
$rs = getdb( "select * from lotto where open>='".date( "Y-m-d" )."' order by open" );
if ( $rs->eof )
{
    err2( "目前没有可以下注期数！" );
}
$lotto_id = $rs->f['id'];
$betmode = intval( $_GET['bmd'] );
global $curruser;
$user = new User();
$userid = $curruser['id'];
$acl = $curruser['acl'];
$protmod = get_protmode( $userid );
$order_id = 1;
if ( 0 < $protmod )
{
    if ( $betmode == 0 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (0,1,2,3,20,24,28,30) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype, numbers";
    }
    else if ( $betmode == 2 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (13,14,18) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 3 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (21,22,37,38,34,35) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 4 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (4,5,6) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype, numbers";
    }
    else if ( $betmode == 5 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (7,8,9,10,11) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype, numbers";
    }
    else if ( $betmode == 6 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype=19 and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 7 )
    {
        $order_id = isset( $_GET['order'] ) ? intval( $_GET['order'] ) : 1;
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (25,26) and numbers like '".$order_id." %' and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 8 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (15,16,17,23) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype, numbers";
    }
    else if ( $betmode == 9 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype=27 and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 10 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype=36 and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype";
    }
    else if ( $betmode == 11 )
    {
        $sql = "select * from bet2 where lotto_id=".$lotto_id." and bettype in (29,39,40,41,42,43,44,45) and user_id=".$userid." and rame in (0,9) order by createtime desc, bettype, numbers";
    }
    $page = isset( $_GET['page'] ) ? intval( $_GET['page'] ) : 1;
    if ( $page == 0 )
    {
        $page = 1;
    }
    $pagesize = 15;
    $rs = getdb( $sql, $page, $pagesize );
    if ( $rs->eof )
    {
        err2( "目前没有补货走飞资料！" );
    }
    echo "<table width=500 border=1 cellpadding=2 cellspacing=0>";
    echo "<tr class=td0><td>序号 / 时间<td nowrap>期数 / 开奖日期<td>走飞内容<td nowrap>赔率<td nowrap>走飞金额<td nowrap>模式";
    $total = 0;
    $movenext = !$rs->eof;
    while ( $movenext )
    {
        ++$items;
        echo "<tr align=right class=td2 onmouseover=msover() onmouseout=msout() valign=top>";
        echo "<td nowrap><font color=#217952>".$rs->f['id']."</font> &nbsp; ".date( "m-d H:i:s", $rs->f['createtime'] );
        $lotto = get_lotto( $rs->f['lotto_id'] );
        echo "<td nowrap>".d3( $lotto->data['round'] )." 期 <font color=#217952>".$lotto->data['open']."</font>";
        echo "<td nowrap>".GetBetContent( $rs->f['bettype'], $rs->f['numbers'], $rs->f['amount'] );
        echo "<td nowrap>".$rs->f['rate'];
        echo "<td nowrap>".$rs->f['amount']."</td>";
        echo "<td nowrap>".( $rs->f['betmode'] == 0 ? "自动" : "手动" )."</td>";
        $total += $rs->f['amount'];
        $rs->movenext();
        $movenext = !$rs->eof;
    }
    echo "<tr class=td1><td colspan=4 align=right><b>合计 ".$items." 笔</b>";
    echo "<td align=right nowrap><b>".$total."</b><td></td>";
    echo "<tr><td class=td0 colspan=11>".$rs->pagelink();
    echo "&#12288;&#12288;<input type=button value=关闭 onclick=\"closeMyList();\"></td></tr>";
    echo "</table>";
    echo "<script>";
    echo "\r\n  if(top != self){ setTimeout(\"if(window.top.mainFrame){window.top.mainFrame.myCloseMyDiv(0);}\",30000); }\r\n  else{ setTimeout(\"window.close();\",30000); } \r\n  function closeMyList(){\r\n    if(top != self){ window.top.mainFrame.myCloseMyDiv(0); }\r\n    else{ window.close(); } \r\n  }\r\n\r\n  ";
    echo "</script>";
}
else
{
    err2( "没有走飞权限！" );
}
echo "\r\n</body>";
?>